public class LoanCalculator {
    int a;
    int m;
    double y;
    double avgCap;
    double avgInt;


    LoanCalculator(int a,int m,double y){
        this.a=a;
        this.m=m;
        this.y=y;
    }
  void avgInterest(){
        avgCap=(m+1)*a*(y/12)/2;
    }
    void avgCaption(){
        double n=Math.pow(1+(y/12),m);
        avgInt=m*a*(y/12)*n/(n-1)-a;
    }
    void print(int type){
        if(type==1){
            System.out.println("等额本金："+avgCap);
        }
        if(type==2){
            System.out.println("等额本息："+avgInt);
        }
    }
}
